﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [System.SerializableAttribute()]
    public class AnonymousUnionListType : global::Xtee.Core.Types.ListTypeBase<AnonymousUnionListType.IComparableType> {
        
        public const string N1235 = "1 2 35";
        
        public const string SMALLMEDIUMLARGE = "small medium large";
        
        public const string SMALLMEDIUM = "small medium";
        
        public AnonymousUnionListType(string value) : 
                base(value) {
            this.Validate();
            string annot = null;
            if (value.ToString() == "1 2 35") {
                annot = "1 2 35";
            }
            if (value.ToString() == "small medium large") {
                annot = "small medium large";
            }
            if (value.ToString() == "small medium") {
                annot = "small medium";
            }
            if (annot!=null) {
                this._annotation = annot;
            }
            else {
                throw new global::Xtee.Core.Types.XteeSimpleTypeValidationException(string.Format("Enumeration on [{0}] does not allow value : [{1}] ", this.GetType().Name,value.ToString()));;
            }
        }
        
        public AnonymousUnionListType() : 
                base(new System.Collections.Generic.List<IComparableType>()) {
        }
        
        public AnonymousUnionListType(System.Collections.Generic.IList<IComparableType> value) : 
                base(value) {
            this.Validate();
            string annot = null;
            if (ToString() == "1 2 35") {
                annot = "1 2 35";
            }
            if (ToString() == "small medium large") {
                annot = "small medium large";
            }
            if (ToString() == "small medium") {
                annot = "small medium";
            }
            if (annot!=null) {
                this._annotation = annot;
            }
            else {
                throw new global::Xtee.Core.Types.XteeSimpleTypeValidationException(string.Format("Enumeration on [{0}] does not allow value : [{1}] ", this.GetType().Name,ToString()));;
            }
        }
        
        public static bool TryParse(string value, out global::Kis.Xroad.Eu.AnonymousUnionListType result) {
            try {
                result = new global::Kis.Xroad.Eu.AnonymousUnionListType(value);
                return true;
            }
            catch (System.Exception ) {
                result = null;
                return false;
            }
        }
        
        public static global::Kis.Xroad.Eu.AnonymousUnionListType Parse(string value) {
            global::Kis.Xroad.Eu.AnonymousUnionListType _AnonymousUnionListType = null;
            if (global::Kis.Xroad.Eu.AnonymousUnionListType.TryParse(value,out _AnonymousUnionListType)) {
                return new AnonymousUnionListType(_AnonymousUnionListType);
            }
             throw new FormatException("Cannot parse to type [global::Kis.Xroad.Eu.AnonymousUnionListType] from string value : [" + value + "]");;
        }
        
        public override IComparableType ParseElement(string value) {
            return new IComparableType(value);
        }
        
        [System.SerializableAttribute()]
        public class IComparableType : global::Kis.Xroad.Eu.SimpleUnion2 {
            
            public IComparableType(global::Xtee.Core.Schema.XsdInt value) : 
                    base((System.Int32)value) {
                this.Validate();
            }
            
            public IComparableType(global::Xtee.Core.Schema.XsdToken value) : 
                    base((System.String)value) {
                this.Validate();
            }
            
            public IComparableType(StringType0 value) : 
                    base((System.String)value) {
                this.Validate();
            }
            
            public IComparableType() : 
                    base(string.Empty) {
            }
            
            public IComparableType(string value) : 
                    base(Parse(value).Value.ToString()) {
                this.Validate();
            }
            
            public static bool TryParse(string value, out IComparableType result) {
                try {
                    result = new IComparableType(value);
                    return true;
                }
                catch (System.Exception ) {
                    result = null;
                    return false;
                }
            }
            
            public static IComparableType Parse(string value) {
                global::Xtee.Core.Schema.XsdInt _XsdInt = null;
                if (global::Xtee.Core.Schema.XsdInt.TryParse(value,out _XsdInt)) {
                    return new IComparableType(_XsdInt);
                }
                global::Xtee.Core.Schema.XsdToken _XsdToken = null;
                if (global::Xtee.Core.Schema.XsdToken.TryParse(value,out _XsdToken)) {
                    return new IComparableType(_XsdToken);
                }
                StringType0 _StringType0 = null;
                if (StringType0.TryParse(value,out _StringType0)) {
                    return new IComparableType(_StringType0);
                }
                 throw new FormatException("Cannot parse to type [IComparableType] from string value : [" + value + "]");;
            }
        }
    }
}
